﻿/*
 * This file is part of CommunitySettlers.
 *
 * CommunitySettlers is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * CommunitySettlers is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with CommunitySettlers.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Author: Christoph Husse
 * 
 * Also checkout our homepage: http://communitysettlers.codeplex.com/
 */
using System;
using System.Windows;

namespace SettlersEngine.Exported
{
    public class SelectionModel : DependencyObject
    {
        public static DependencyPropertyKey HasBuildingPropertyKey = DependencyProperty.RegisterReadOnly("HasBuilding", typeof(Boolean), typeof(BuildingListener), new PropertyMetadata(false));
        public static DependencyPropertyKey BuildingPropertyKey = DependencyProperty.RegisterReadOnly("Building", typeof(BuildingListener), typeof(BuildingListener), new PropertyMetadata(null));

        public static DependencyProperty HasBuildingProperty = HasBuildingPropertyKey.DependencyProperty;
        public static DependencyProperty BuildingProperty = BuildingPropertyKey.DependencyProperty;

        public event DNotifyHandler<SelectionModel> OnChanged;

        public Boolean HasBuilding
        {
            get { return (Boolean)GetValue(HasBuildingProperty); }
        }

        public BuildingListener Building
        {
            get { return (BuildingListener)GetValue(BuildingProperty); }
            set
            {
                SetValue(BuildingPropertyKey, value);
                SetValue(HasBuildingPropertyKey, value != null);

                OnChanged(this);
            }
        }
    }
}
